<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    const arr = [1, 2, 3, 4, 5, 3, 2, 1, 6, 4, 7, 8]

    let arr2 = arr.reduce((pre, cur) => {
        return pre.includes(cur) ? pre : pre.concat(cur)
    }, [])

    console.log(arr2)

    let arr3 = arr.filter((item, index,o) => {
        return o.indexOf(item) === index
    })
    console.log(arr3)
</script>
</body>
</html>